Migration and Post-Migration script example for Windows

Below a batch script (.bat) to first execute a migration of projects given in parameters (zip), then execute 3 command lines on each project after migration: Refresh Representations, Remove Hidden Elements, and Export All Representations as images.

To execute it:

thisScript.bat #absolutePathToProjectA.zip #absolutePathToProjectB.zip #absolutePathToProjectC.zip

If you migrate a project using libraries, all dependent projects/libraries must be included and the sequence order matters.

@echo off
setlocal enabledelayedexpansion

rem Mandatory to set

set capellaExe=...capella/capellac.exe
set workspacePath=.../workspace
set logFilePath=".../log.html"

rem compute importedFiles (".../projectA.zip | .../projectB.zip | ...")

SET projectsList=
for %%x in (%*) do (
  set projectsList=!projectsList! ^| %%x
)
set importedFiles=!projectsList:~3!

rem First, execute the migration on the given projects

echo Execute migration of all given projects:
@echo on
%capellaExe% -nosplash -application org.polarsys.capella.core.commandline.core -appid org.polarsys.capella.migration -data "%workspacePath%" -import "%importedFiles%" -input /all -outputfolder "A_ok/MigrationResult" -backup -logfile "%logFilePath%"
@echo off
echo.
rem execute the refreshRepresentations command line
  set command1=%capellaExe% -nosplash -application org.polarsys.capella.core.commandline.core -appid org.polarsys.capella.refreshRepresentations -data "%workspacePath%" -input /all -unsyncDiags -logfile "%logFilePath%"
  echo !command1!
  call !command1!
  echo.
 rem execute the removeHiddenElements command line
  set command2=%capellaExe% -nosplash -application org.polarsys.capella.core.commandline.core -appid org.polarsys.capella.removeHiddenElements -data "%workspacePath%" -input /all -unsyncDiags -logfile "%logFilePath%"
  echo !command2!
  call !command2!
echo.
 rem execute the exportRepresentations command lines and at the end of all commands, all the models are exported to output location "/MigratedProject/output"
  set command3=%capellaExe% -nosplash -application org.polarsys.capella.core.commandline.core -appid org.polarsys.capella.exportRepresentations  -data "%workspacePath%" -input /all -exportToHTML -exportZip /all -outputfolder /MigratedProject/output
  echo !command3!
  call !command3!
  echo.
)
@echo on